The analysis of the normalized distribution of musical keys across Afro House, Deep House, and Melodic House genres reveals some intriguing patterns. C# emerges as the predominant key in both Afro House and Melodic House, indicating a preference for its sound qualities in these genres. The choice of key can affect the mood and energy of the music. C#, being a semi-tone higher than C, is often considered to have a bright and lively quality which might resonate well with the energetic and emotive nature of Afro House and the ethereal, uplifting atmosphere of Melodic House.
In contrast, G is the most popular key in Deep House, which may underscore the genre’s tendency towards a deeper, more mellow sonic palette. The key of G is often associated with a warm and inviting tone, which complements Deep House’s soulful and laid-back vibe. This key can provide a comfortable harmonic foundation for the smooth grooves and relaxed rhythms characteristic of this genre.
The preference for these keys suggests that artists and producers are likely to lean towards certain tonalities that align with the expressive needs of their genre. While this trend does not dictate the creative choices made in music production, it highlights the subtle ways in which key selection can contribute to genre-specific atmospheres and listener expectations.
My corpus is a collection with songs of three different genres, namely: Afro House, Deep House, and Melodic House. These genres are all subgenres of house, which makes them interesting to study to find out what distinguishes these genres. Each genre has its own unique blend of rhythm, melodies, and textures which make them very suitable for analysis.
Afro House, with its rhythmic energy and African influences, contrasts with Melodic House’s emotive soundscapes and Deep House’s soulful grooves. This selection aims to explore the auditory and emotional distinctions and intersections among these genres. I expect differences in their rhythmic structure; Afro House has more complex rhythms, whereas Deep House and Melodic House have simpler rhythms. The mood of the genres also differs, from Deep House’s mellow vibes to Afro House’s energy and Melodic House’s ethereal qualities, yet their base structure is similar.
My corpus consists of dozens of songs for every genre, aiming for a diverse range of artists and songs that represent each genre. However a potential gap in my corpus is the focus on relatively recent releases which does not take the history of each genre into account. Also my corpus does potentially miss niche songs that could offer additional insights into each genre.
Typical songs for each genre are: Ben Bohmer - Beyond Beliefs for Melodic House, Rampa - Champion for Afro House, and Mahalo - Home for Deep House, embodying each genre’s core values. Atypical songs like Notre Dame - Yumi - edit for Melodic House, Sebjak - Somebody - edit for Afro House, and Hannah Laing - Good Love for Deep House, are chosen for their unusual rhythm and tempo, offering additional insights into each genre.
This plot is a scatterplot displaying the relationship between ‘Energy’ and ‘Valence’ for the three different genres of music: Afro House, Deep House, and Melodic House. Each panel represents one of the genres, plotted with ‘Energy’ on the x-axis and ‘Valence’ on the y-axis. The data points for Afro House are colored blue, for Deep House they are red, and for Melodic House they are green. The spread of data points in each genre-specific panel indicates the distribution of the tracks according to their energy and valence characteristics within that genre.
It is interesting to see how the three different genres I chose for my analysis compare in terms of their energy and valence. This plot provides insights into the emotional characteristics of each genre. For example, we can visually conclude that Melodic House is considered the least positive of the three genres according to Spotify. This makes sense since it’s the more emotional genre.
This plot is a heatmap that visualizes the intensity of pitch classes over time within the song “Breathing” by Ben Böhmer. The choice for this song was not because it was a pitch related outlier, but because it was a tempo related outlier. The horizontal axis represents time in seconds, and the vertical axis indicates the pitch classes. Intensity levels are depicted through a color gradient, transitioning from blue for lower intensities to red for higher intensities.
These are the self-similarity matrices for Chroma and Timbre for our tempo outlier ‘Breathing’ by Ben Bohmer.
---
title: "Analysis of Genre Audio Features"
output:
flexdashboard::flex_dashboard:
css: dashboard-styles.css
theme: simplex
social: menu
source: embed
---
```{r setup, include=FALSE}
library(flexdashboard)
library(spotifyr)
library(dplyr)
library(ggplot2)
library(reshape2)
library(tidyr)
library(ggforce)
library(tibble)
library(purrr)
library(compmus)
```
```{r}
Sys.setenv(SPOTIFY_CLIENT_ID = Sys.getenv("SPOTIFY_CLIENT_ID"))
Sys.setenv(SPOTIFY_CLIENT_SECRET = Sys.getenv("SPOTIFY_CLIENT_SECRET"))
access_token <- get_spotify_access_token()
# Fetching data
playlist_id <- "1RhRAqYJA1mwmBtk4mXRju"
username <- "quintijn.kroesbergen"
all_audio_features_df <- get_playlist_audio_features(username, playlist_uris = c(playlist_id), authorization = access_token)
```
```{r}
# Assigning genres
all_audio_features_df$genre <- NA
all_audio_features_df$genre[1:107] <- 'Afro House'
all_audio_features_df$genre[108:206] <- 'Deep House'
all_audio_features_df$genre[207:284] <- 'Melodic House'
```
# Histograms of keys for the genres
## Visualisation
Column {data-width=500 .plot-column}
-------
```{r}
key_names <- c('C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B')
all_audio_features_df$key_name <- key_names[all_audio_features_df$key + 1]
# Calculate the count of tracks in each key by genre
counts <- all_audio_features_df %>%
group_by(genre, key_name) %>%
summarise(count = n(), .groups = 'drop')
# Calculate the total count of tracks in each genre
total_counts <- counts %>%
group_by(genre) %>%
summarise(total = sum(count), .groups = 'drop')
# Join the counts with total counts and calculate the proportion
counts <- counts %>%
left_join(total_counts, by = "genre") %>%
mutate(proportion = count / total)
# Calculate the most popular key for each genre
most_popular_keys <- counts %>%
group_by(genre) %>%
top_n(1, wt = proportion) %>%
ungroup() %>%
select(genre, key_name, proportion)
ymax_limit <- max(counts$proportion) * 1.3
muted_colors <- c('Afro House' = '#377eb8', # Muted blue
'Deep House' = '#e41a1c', # Muted red
'Melodic House' = '#4daf4a') # Muted green
# Create the histogram plot
p <- ggplot(counts, aes(x = key_name, y = proportion, fill = genre)) +
geom_bar(stat = "identity", position = position_dodge()) +
labs(title = "Normalized Distribution of Keys by Genre",
x = "Musical Key",
y = "Proportion of Tracks") +
scale_fill_manual(values = muted_colors) +
theme_minimal() +
theme(legend.position = "bottom") +
ylim(0, ymax_limit) # Extend y-axis limit
# Add annotations for the most popular keys
p + geom_text(data = most_popular_keys, aes(x = key_name, y = proportion, label = key_name),
position = position_dodge(width = 0.9), vjust = -0.5, color = "black", fontface = "bold")
```
Column {data-width=500 .discussion-column}
-------
The analysis of the normalized distribution of musical keys across Afro House, Deep House, and Melodic House genres reveals some intriguing patterns. C# emerges as the predominant key in both Afro House and Melodic House, indicating a preference for its sound qualities in these genres. The choice of key can affect the mood and energy of the music. C#, being a semi-tone higher than C, is often considered to have a bright and lively quality which might resonate well with the energetic and emotive nature of Afro House and the ethereal, uplifting atmosphere of Melodic House.
In contrast, G is the most popular key in Deep House, which may underscore the genre's tendency towards a deeper, more mellow sonic palette. The key of G is often associated with a warm and inviting tone, which complements Deep House's soulful and laid-back vibe. This key can provide a comfortable harmonic foundation for the smooth grooves and relaxed rhythms characteristic of this genre.
The preference for these keys suggests that artists and producers are likely to lean towards certain tonalities that align with the expressive needs of their genre. While this trend does not dictate the creative choices made in music production, it highlights the subtle ways in which key selection can contribute to genre-specific atmospheres and listener expectations.
# Introduction of Corpus
My corpus is a collection with songs of three different genres, namely: Afro House, Deep House, and Melodic House. These genres are all subgenres of house, which makes them interesting to study to find out what distinguishes these genres. Each genre has its own unique blend of rhythm, melodies, and textures which make them very suitable for analysis.
Afro House, with its rhythmic energy and African influences, contrasts with Melodic House's emotive soundscapes and Deep House's soulful grooves. This selection aims to explore the auditory and emotional distinctions and intersections among these genres. I expect differences in their rhythmic structure; Afro House has more complex rhythms, whereas Deep House and Melodic House have simpler rhythms. The mood of the genres also differs, from Deep House's mellow vibes to Afro House's energy and Melodic House's ethereal qualities, yet their base structure is similar.
My corpus consists of dozens of songs for every genre, aiming for a diverse range of artists and songs that represent each genre. However a potential gap in my corpus is the focus on relatively recent releases which does not take the history of each genre into account. Also my corpus does potentially miss niche songs that could offer additional insights into each genre.
Typical songs for each genre are: Ben Bohmer - Beyond Beliefs for Melodic House, Rampa - Champion for Afro House, and Mahalo - Home for Deep House, embodying each genre's core values. Atypical songs like Notre Dame - Yumi - edit for Melodic House, Sebjak - Somebody - edit for Afro House, and Hannah Laing - Good Love for Deep House, are chosen for their unusual rhythm and tempo, offering additional insights into each genre.
# Harmony in Motion: Exploring Genre Energies and Emotions
## Visualization and Description of first visualisation
Column {data-width=750 .plot-column}
-------
```{r, align='center'}
# Plotting the graph
ggplot(all_audio_features_df, aes(x = energy, y = valence, color = genre)) +
geom_point() +
labs(title = "Energy vs Valence by Genre",
x = "Energy",
y = "Valence",
color = "Genre") +
scale_color_manual(values = muted_colors) + # Use the muted colors here
theme_minimal() +
theme(legend.position = "right")
```
Column {data-width=250 .discussion-column}
-------
This plot is a scatterplot displaying the relationship between 'Energy' and 'Valence' for the three different genres of music: Afro House, Deep House, and Melodic House. Each panel represents one of the genres, plotted with 'Energy' on the x-axis and 'Valence' on the y-axis. The data points for Afro House are colored blue, for Deep House they are red, and for Melodic House they are green. The spread of data points in each genre-specific panel indicates the distribution of the tracks according to their energy and valence characteristics within that genre.
It is interesting to see how the three different genres I chose for my analysis compare in terms of their energy and valence. This plot provides insights into the emotional characteristics of each genre. For example, we can visually conclude that Melodic House is considered the least positive of the three genres according to Spotify. This makes sense since it's the more emotional genre.
# Sonic Spectrum: Mapping Pitch Class Intensity Over Time
## Visualisation
Column {data-width=750 .plot-column}
-------
```{r, align='center'}
track_id <- "1MvLmHeLkaNgUScgbUVnWJ"
audio_analysis <- get_tidy_audio_analysis(track_id)
# Select and unnest segments, then select start, duration, and pitches
chroma_data <-
audio_analysis %>%
select(segments) %>%
unnest(segments) %>%
select(start, duration, pitches)
# Process and plot chroma data
chroma_plot <-
chroma_data %>%
mutate(pitches = map(pitches, compmus_normalise, "euclidean")) %>%
compmus_gather_chroma() %>%
ggplot(
aes(
x = start + duration / 2,
width = duration,
y = pitch_class,
fill = value
)
) +
geom_tile() +
labs(
x = "Time (s)",
y = NULL,
fill = "Magnitude",
title = "Chroma Features Over Time for \nfor 'Breathing' by Ben Bohmer"
) +
theme_minimal() +
scale_fill_viridis_c()
# Print the plot
print(chroma_plot)
```
Column {data-width=250 .discussion-column}
-------
This plot is a heatmap that visualizes the intensity of pitch classes over time within the song "Breathing" by Ben Böhmer. The choice for this song was not because it was a pitch related outlier, but because it was a tempo related outlier. The horizontal axis represents time in seconds, and the vertical axis indicates the pitch classes. Intensity levels are depicted through a color gradient, transitioning from blue for lower intensities to red for higher intensities.
# Self-similarity for Chroma and Timbre
## Visualisation
Column {data-width=750 .plot-column}
-------
```{r}
track_audio_analysis <- get_tidy_audio_analysis(track_id)
# Example adapted for your selected track (assuming 'track_audio_analysis' contains your data)
bzt <- track_audio_analysis |>
compmus_align(bars, segments) |>
select(bars) |>
unnest(bars) |>
mutate(
pitches = map(segments, compmus_summarise, pitches, method = "acentre", norm = "manhattan"),
timbre = map(segments, compmus_summarise, timbre, method = "mean")
)
# Create self-similarity matrices for both chroma and timbre
ssm_data <- bind_rows(
bzt |> compmus_self_similarity(pitches, "aitchison") |> mutate(d = d / max(d), type = "Chroma"),
bzt |> compmus_self_similarity(timbre, "euclidean") |> mutate(d = d / max(d), type = "Timbre")
)
# Plotting
# Assuming ssm_data is already defined and contains the data for plotting
# Assuming ssm_data is already defined and contains the data for plotting
ssm_data |>
ggplot(
aes(
x = xstart + xduration / 2,
y = ystart + yduration / 2,
width = xduration,
height = yduration,
fill = d
)
) +
geom_tile() +
facet_wrap(~type) +
scale_fill_viridis_c(option = "E", guide = "none") +
theme_minimal() +
theme(
strip.text.x = element_text(size = 10),
plot.title.position = "plot",
# Use this if you do not want to show any axis ticks
) +
labs(
title = "Self-Similarity Matrices for Chroma and Timbre\nfor 'Breathing' by Ben Bohmer",
x = "Time (s)", # Label for x-axis
y = "Time (s)" # Label for y-axis
) +
coord_fixed(ratio = 1) # This enforces a 1:1 aspect ratio
```
Column {data-width=250 .discussion-column}
-------
These are the self-similarity matrices for Chroma and Timbre for our tempo outlier 'Breathing' by Ben Bohmer.